package com.gf.framework.translatordemo.translator;

import com.gf.framework.web.translate.Translatable;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.Period;

/**
 * @author gaofei
 * @Description
 * @create 2022/5/26 11:39
 */
@Component
public class StudentAgeTranslator implements Translatable<LocalDate, Integer> {
    @Override
    public Integer translate(LocalDate original, Class<?> datasource, String param) {
        LocalDate nowDate = LocalDate.now();
        Period next = Period.between(original, nowDate);
        return next.getYears();
    }
}
